<template>
	<view style="min-height: 100vh;background-color: #F3F3F3;">
		<view style="position: fixed;top: 0;left: 0;width: 100%;z-index: 999;">
			<view class="searchWrap">
				<view class="searchL">
					<image src="../../static/mine/search_ico.png"></image>
					<input type="text" placeholder="搜索关键词" />
				</view>
				<view class="searchR">搜索</view>
			</view>
			<view class="navWrap">
				<view>
					<view :class="['navItem',navIndex==index?'active':'']" v-for="(item,index) in navList" :key="index" :data-index="index" @click="selectNav">{{item}}</view>
				</view>
				
			</view>
		</view>
		<view class="conWrap" v-if="list.length>0">
			<view class="conItem" v-for="(item,index) in list" :key="index" @click="toOrderInfo" :data-index="index">
				<view class="conItemHead">
					<view class="conItemHeadL">
						<view class="conItemHeadLL">
							<image src="../../static/mine/title_ico.png"></image>
						</view>
						<view class="conItemHeadLR">
							{{item.ShopEvaluation.title}}
						</view>
					</view>
					<view class="conItemHeadR" v-if="form=='user'&&navIndex==1">被邀请</view>
					<view class="conItemHeadR" v-if="form=='shop'&&navIndex==1">已邀请</view>
					<view class="conItemHeadR" v-if="item.type==0&&navIndex!=1">待确认</view>
					<view class="conItemHeadR" v-if="(item.type==1||item.type==2)&&navIndex!=1">待预约</view>
					<view class="conItemHeadR" v-if="item.type==3&&navIndex!=1">待到店</view>
					<view class="conItemHeadR" v-if="item.type==4&&navIndex!=1">待交稿</view>
					<view class="conItemHeadR" v-if="(item.type==5||item.type==6||item.type==7)&&navIndex!=1">待审核</view>
					<!-- <view class="conItemHeadR" v-if="item.type==6&&navIndex!=1">待发布</view>
					<view class="conItemHeadR" v-if="item.type==7&&navIndex!=1">待查收</view> -->
					<view class="conItemHeadR" v-if="item.type==8&&navIndex!=1">已完成</view>
					<view class="conItemHeadR" v-if="item.type==9&&navIndex!=1">已过期</view>
				</view>
				<view class="conItemC">
					<image v-if="item.ShopEvaluation.ShopEvaluationExampleImage" :src="getImage(item.ShopEvaluation.ShopEvaluationExampleImage[0].image_url)"></image>
					<view class="conItemCR">
						<view class="conItemCRT">
							<view class="conItemCRTL" v-if="item.ShopEvaluation.platform==1"><image src="../../static/mine/douyin_white.png"></image></view>
							<view class="conItemCRTL" style="background: #F40A0B;" v-if="item.ShopEvaluation.platform==2"><image style="width: 38upx;height: 16upx;" src="../../static/mine/xiaohongshu_white.png"></image></view>
							<view class="conItemCRTL" style="background: #FFD974;" v-if="item.ShopEvaluation.platform==3"><image style="width: 24upx;height: 22upx;" src="../../static/mine/weibo_white.png"></image></view>
							<view class="conItemCRTL" style="background: #F36326;" v-if="item.ShopEvaluation.platform==4"><image style="width: 20upx;height: 20upx;" src="../../static/mine/dazong_white.png"></image></view>
							<view class="conItemCRTR">粉丝数{{item.ShopEvaluation.fans_num}}以上<text v-if="item.ShopEvaluation.platform==4">;等级{{item.ShopEvaluation.public_grade}}以上</text></view>
						</view>
						<view class="conItemCRC">稿费：<text>￥{{item.ShopEvaluation.talent_money}}</text></view>
						<view class="conItemCRB" v-if="item.Shop">地址：{{item.Shop.detailed_address}}</view>
					</view>
				</view>
				<view class="conItemBWrap">
					<view style="font-size: 28rpx;line-height: 28rpx;" @click.stop="toChat" :data-id="form=='user'?item.business_id:item.user_id">
						下单用户：{{item.user.username}}
					</view>
					<view>
						<view class="conItemB" v-if="navIndex==1&&form=='user'">
							<view class="replyApply" v-if="item.is_accept==0" style="margin-right: 30upx;background: #D0D0D0;color: #333333;" @click.stop="refuse" :data-index="index" :data-id="item.id" :data-ids="item.shop_evaluation_id">拒绝邀请</view>
							<view class="replyApply" v-if="item.is_accept==0" @click.stop="accept" :data-money="item.ShopEvaluation.frozen_money" :data-id="item.shop_evaluation_id" :data-ids="item.shop_id">接受邀请</view>
							<view class="replyApply" v-if="item.is_accept==1">待商家确认</view>
							<view class="replyApply" v-if="item.is_accept==2">已拒绝</view>
							<view class="replyApply" v-if="item.is_accept==3">已过期</view>
						</view>
						<view class="conItemB" v-if="navIndex==1&&form=='shop'">
							<view class="replyApply" v-if="item.is_accept==0">已邀请</view>
							<view class="replyApply" v-if="item.is_accept==2">已拒绝</view>
							<view class="replyApply" v-if="item.is_accept==3">已过期</view>
						</view>
						<view class="conItemB" v-if="form=='user'&&navIndex!=1">
							<view class="replyApply" v-if="item.type==0">待商家确认</view>
							<picker mode="date" :start="startTime" :end="endTime" @change="selectTime" :data-pid="item.shop_evaluation_id" :data-id="item.id" v-if="item.type==1&&!item.appointment_time">
								<view class="replyApply" v-if="item.type==1">预约到店</view>
							</picker>
							<picker mode="date" :start="startTime" :end="endTime" @change="selectTime" :data-pid="item.shop_evaluation_id" :data-id="item.id" v-if="item.type==1&&item.appointment_time">
								<view class="replyApply">修改预约</view>
							</picker>
							<view class="replyApply" v-if="item.type==2">待商家确认</view>
							<picker style="margin-right: 30upx;" mode="date" :start="startTime" :end="endTime" @change="selectTime" :data-pid="item.shop_evaluation_id" :data-id="item.id" v-if="item.type==3&&item.appointment_time">
								<view class="replyApply">修改预约</view>
							</picker>
							<view class="replyApply" v-if="item.type==3" @click.stop="sureToStore" :data-id="item.id">确认到店</view>
							<view class="replyApply" v-if="item.type==4&&!item.share_id" :data-id="item.id" @click.stop="toRelease">交稿</view>
							<view class="replyApply" v-if="item.type==4&&item.share_id" :data-ids="item.share_id" :data-id="item.id" @click.stop="toRelease">修改稿件</view>
							<view class="replyApply" v-if="item.type==5">待审核</view>
							<view class="replyApply" v-if="item.type==6" @click.stop="sureRelease" :data-id="item.id">我已发布</view>
							<view class="replyApply" v-if="item.type>=6" @click.stop="toShUser" :data-id="item.id">申诉</view>
							<view class="replyApply" v-if="item.type==7">待商家查收</view>
							<view class="replyApply" v-if="item.type==8">已完成</view>
							<view class="replyApply" v-if="item.type==9">已过期</view>
						</view>
						<view class="conItemB" v-if="form=='shop'&&navIndex!=1">
							<view class="replyApply" v-if="item.type==0" :data-id="item.id" :data-money="item.money" @click.stop="sureOrder">确认订单</view>
							<view class="replyApply" v-if="item.type==1">待预约</view>
							<view class="replyApply" v-if="item.type==2" @click.stop="sureAppoint" data-type="refuse" :data-id="item.id" style="margin-right: 30upx;">需要修改</view>
							<view class="replyApply" v-if="item.type==2" @click.stop="sureAppoint" data-type="pass" :data-id="item.id">确认预约</view>
							<view class="replyApply" v-if="item.type==3">待达人到店</view>
							<view class="replyApply" v-if="item.type==4">待交稿</view>
							<view class="replyApply" v-if="item.type==5" :data-type="item.imgType" :data-id="item.share_id" @click.stop="checkMsg" style="margin-right: 30upx;">查看</view>
							<view class="replyApply" v-if="item.type==5" @click.stop="surePass" data-type="refuse" :data-id="item.id" style="margin-right: 30upx;">需修改</view>
							<view class="replyApply" v-if="item.type==5" @click.stop="surePass" data-type="pass" :data-id="item.id">可发布</view>
							<view class="replyApply" v-if="item.type==6">待发布</view>
							<view class="replyApply" v-if="item.type==7" @click.stop="noOver" :data-id="item.id" style="margin-right: 30upx;">未收到</view>
							<view class="replyApply" v-if="item.type==7" @click.stop="sureOver" :data-id="item.id">完成查收</view>
							<view class="replyApply" v-if="item.type==8" @click.stop="toSh" :data-id="item.id">申请售后</view>
							<view class="replyApply" v-if="item.type==9">已过期</view>
						</view>
					</view>
				</view>
				
			</view>
		</view>
		<view v-if="list.length==0" style="padding-top: 400upx;">
			<u-empty></u-empty>
		</view>
		<view class="toastMark" v-if="markFlag" @click="markFlag=false"></view>
		<view class="toastWrap" v-if="markFlag">
			<view class="toastWrapTit">
				报名将冻结您的余额<text>{{djMoney}}</text>元
			</view>
			<view class="toastWrapCon">到店后逾期不交稿或交稿后删稿，该金额将扣除用于结付给商户；正常交稿后7天无商户的删稿投诉，该金额与稿费同步解冻。</view>
			<view class="toastBtn">
				<view class="later" @click="markFlag=false">稍后</view>
				<view class="onSure" @click="toSubmit">确认</view>
			</view>
		</view>
		<view class="toastMark" v-if="sureToStoreFlag" @click="sureToStoreFlag=false"></view>
		<view class="toastWrap" v-if="sureToStoreFlag">
			<view class="toastWrapTit" style="text-align: center;">
				确认到店
			</view>
			<view class="toastWrapCon" style="color: #333333;text-align: center;">如确认到店但无法交稿将</view>
			<view class="toastWrapCon" style="color: red;margin-top: 30upx;text-align: center;">扣除测评冻结金额</view>
			<view class="toastBtn">
				<view class="later" @click="sureToStoreFlag=false">暂未到店</view>
				<view class="onSure" @click="sureToStoreFun">我已到店</view>
			</view>
		</view>
		<number-jpan :length="6" @closeChange="closeChange($event)" :showNum="false" ref="numberPad"></number-jpan>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	const app = getApp();
	import {wxPayment,zfbPayment} from "@/utils/app.js";
	import numberJpan from "@/components/numberJpan/numberJpan.vue";
	export default {
		data() {
			return {
				sureToStoreFlag:false,
				navList:[],
				navIndex:0,
				list:[],
				page:1,
				moreFlag:false,
				form:"",
				sureOrderData:{},
				startTime:"",
				endTime:"",
				orderIds:"",
				acceptId:"",
				djMoney:0,
				markFlag:false,
				nowOrderId:""
			}
		},
		components:{'number-jpan':numberJpan},
		onReachBottom() {
			if(!this.moreFlag){
				return false;
			}
			this.moreFlag = false;
			this.page = this.page + 1;
			if(this.navIndex==1){
				this.getNews();
			}else{
				this.getList();
			}
		},
		onLoad(options) {
      // #ifdef APP-PLUS
      var args = plus.runtime.arguments;
      if(args){
        app.$vm.setShareDetail(args);
      }
      // #endif
			this.startTime = app.$vm.getTime(new Date().getTime(),"-","day");
			this.endTime = app.$vm.getTime(new Date().getTime()+30*24*60*60*1000,"-","day");
			if(options.type){
				this.navIndex = options.type;
			}
			if(options.form){
				this.form = options.form;
				if(this.form == "user"){
					uni.setNavigationBarTitle({
						title:"我的创作"
					})
					this.navList = ["全部","被邀请","待确认","待预约","待到店","待交稿","待审核","已完成"];
				}else{
					uni.setNavigationBarTitle({
						title:"营销管理"
					})
					this.navList = ["全部","已邀请","待确认","待预约","待到店","待交稿","待审核","已完成"];
				}
			}
			if(this.navIndex==1){
				this.getNews();
			}else{
				this.getList();
			}
			
		},
		methods: {
			toChat(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				uni.navigateTo({
					url:"/pages/pageone/pages/ChatBox/ChatBox?id="+id
				})
			},
			toOrderInfo(e){
				let index = e.target.dataset.index || e.currentTarget.dataset.index;
				console.log(index)
				if(this.navIndex==1){
					uni.navigateTo({
						url:"/pages/pageone/pages/ActivityDetails/ActivityDetails?id="+this.list[index].shop_evaluation_id
					})
				}else{
					uni.navigateTo({
						url:"/pages/pageone/pages/ActivityDetails/ActivityDetails?id="+this.list[index].shop_evaluation_id
					})
				}
			},
			noOver(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let obj = {};
				obj.id = id;
				this.$u.api.shopEvaluationOrderShopReject(obj).then(res=>{
          //推送消息
          this.$u.api.shopEvaluationOrderDetails({
            id: id
          }).then(res => {
            let objsend = {};
            let user = uni.getStorageSync("rmUser");
            objsend.user_id = res.data.details.user_id;
            objsend.title = "查收异常";
            objsend.content = '查收异常-' + res.data.details.ShopEvaluation.title +
                '发布内容商家查收异常，请检查所发布的账户、平台、关联店铺等信息发布后再次点击；如确认无误请点击（申述）';
            objsend.payload = `/pages/pagethree/pages/myCreation/myCreation?form=user&type=0`;
            app.$vm.sendPushMes(objsend);
          });
					this.$refs.uToast.show({
						title:"已驳回",
						type:"success",
						duration:2000
					})
				})
			},
			toSh(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				uni.navigateTo({
					url:"/pages/pagethree/pages/explain/explain?type=shop&id="+id
				})
			},
			toShUser(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				uni.navigateTo({
					url:"/pages/pagethree/pages/explain/explain?type=user&id="+id
				})
			},
			sureAppoint(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let type = e.target.dataset.type || e.currentTarget.dataset.type;
				let obj = {};
				obj.id = id;
				if(type=="refuse"){
					obj.is_agree = 2;
				}else{
					obj.is_agree = 1;
				}
				this.$u.api.shopEvaluationOrderShopRefuseAppointmentTime(obj).then(res=>{
					if(type=="refuse"){
            //推送消息
            this.$u.api.shopEvaluationOrderDetails({
              id: id
            }).then(res => {
              let objsend = {};
              let user = uni.getStorageSync("rmUser");
              objsend.user_id = res.data.details.user_id;
              objsend.title = "驳回消息";
              objsend.content = '预约未成功，请与PR沟通后再次登记预约信息-谢谢参与！';
              objsend.payload =
                  `/pages/pagethree/pages/myCreation/myCreation?form=user&type=0`;
              app.$vm.sendPushMes(objsend);
            });
						this.$refs.uToast.show({
							title:"已驳回预约",
							type:"success",
							duration:2000
						})
						this.page = 1;
						this.navIndex = 3;
						this.getList();
					}else{
            //推送消息
            this.$u.api.shopEvaluationOrderDetails({
              id: id
            }).then(res => {
              let objsend = {};
              let user = uni.getStorageSync("rmUser");
              objsend.user_id = res.data.details.user_id;
              objsend.title = "确认消息";
              objsend.content = '请按时参与测评订单，商家' + user.username + '已确认预约时间,请按时参与！';
              objsend.payload =
                  `/pages/pagethree/pages/myCreation/myCreation?form=user&type=0`;
              app.$vm.sendPushMes(objsend);
            });
						this.$refs.uToast.show({
							title:"已确认预约",
							type:"success",
							duration:2000
						})
						this.page = 1;
						this.navIndex = 4;
						this.getList();
					}
				})
			},
			toSubmit(){
				this.markFlag = false;
				this.$refs.numberPad.open("需冻结"+this.djMoney+"元");
			},
			refuse(e){
				uni.showModal({
					content:"确定要拒绝吗?",
					success:res=>{
						if(res.confirm){
							let id = e.target.dataset.id || e.currentTarget.dataset.id;
							let id1 = e.target.dataset.ids || e.currentTarget.dataset.ids;
							let index = e.target.dataset.index || e.currentTarget.dataset.index;
							let obj = {};
							obj.id = id;
							obj.shop_evaluation_id = id1;
							app.$vm.sendMessage(obj);
							let objs = {};
							objs.main_user_id = uni.getStorageSync("userId");
							objs.vice_user_id = this.list[index].main_user_id == uni.getStorageSync("userId") ? this.list[index].vice_user_id : this.list[index].main_user_id;
							objs.type = 1;
							objs.news = "不好意思，先不参加了";
							app.$vm.sendMessage(objs);
							let dataObj = this.list[index];
							dataObj.is_accept = 2;
							this.list.splice(index,1,dataObj);
              //推送给商家
              let user_id = objs.vice_user_id;
              let me = uni.getStorageSync("userId")
              let rmUser = uni.getStorageSync("rmUser")
              let objj = {};
              objj.user_id = user_id;
              objj.title = "订单取消";
              objj.content = "订单取消通知\n" + rmUser.username + "用户拒绝了你的邀请，看看其他达人吧！\n";
              objj.payload = "";
              app.$vm.sendPushMes(objj);
							this.$refs.uToast.show({
								title:"已拒绝",
								type:"success",
								duration:2000
							})
						}
					}
				})
				
			},
			accept(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let id1 = e.target.dataset.ids || e.currentTarget.dataset.ids;
				let money = e.target.dataset.money || e.currentTarget.dataset.money;
				this.acceptId = id;
				// this.acceptShopId = id1;
				this.status = "yq";
				this.djMoney = money;
				this.markFlag = true;
				// this.$refs.numberPad.open("需冻结"+money+"元");
			},
			closeChange(e){
				if(this.status=="yq"){
					let obj = {};
					obj.payPassword = e;
					obj.shop_evaluation_id = this.acceptId;
					// obj.shop_id = this.acceptShopId;
					if(app.$vm.globalData.shareid&&app.$vm.globalData.cpid==obj.shop_evaluation_id){
						obj.share_user_id = app.$vm.globalData.shareid;
					}
					obj.is_accept = 1;
					this.$u.api.shopEvaluationOrderAdd(obj).then(res=>{
						console.log(res)
						this.$refs.uToast.show({
							title:"已接受，请等待商家确认",
							type:"success",
							duration:2000
						})
						this.page = 1;
						this.navIndex = 2;
						this.getList();
					})
					.catch(err=>{
						console.log(err)
						if(err.message == "请先设置支付密码"){
							uni.navigateTo({
								url:"/pages/pageone/pages/ChangePassword1/ChangePassword1"
							})
						}else if(err.message == "您尚未认证名片"){
							uni.navigateTo({
								url:"/pages/pagefour/pages/real/real"
							})
						}
					})
				}else{
					this.sureOrderData.pay_password = e;
					this.sureOrderFun();
				}
			},
			getNews(){
				let obj = {};
				obj.page = 1;
				if(this.form=='user'){
					obj.is_business = 2;//1商家 2用户
				}else{
					obj.is_business = 1;//1商家 2用户
				}
				this.$u.api.newsList(obj).then(res=>{
					console.log(res)
					this.list = res.data.list.data.map(cur=>{
						cur.ShopEvaluation = {};
						this.$u.api.shopEvaluationDetails({id:cur.shop_evaluation_id}).then(resl=>{
							cur.ShopEvaluation = resl.data.details;
						})
						return cur;
					})
				})
			},
			sureOver(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let obj = {};
				obj.id = id;
				this.$u.api.shopEvaluationOrderShopConfirmRelease(obj).then(res=>{
          //推送消息
          this.$u.api.shopEvaluationOrderDetails({
            id: id
          }).then(res => {
            let objsend = {};
            let user = uni.getStorageSync("rmUser");
            objsend.user_id = res.data.details.user_id;
            objsend.title = "发布消息";
            objsend.content = "稿费到账通知" + res.data.details.ShopEvaluation.title + "-" + user.username +
                "${达人若免昵称}活动已完成，稿费已到账冻结账户，7天后将与商品押金同步自动解冻！谢谢参与！"
            objsend.payload = `/pages/pagethree/pages/myCreation/myCreation?form=user&type=0`;
            app.$vm.sendPushMes(objsend);
          });

					this.$refs.uToast.show({
						title:"已确认完结",
						type:"success",
						duration:2000
					})
					this.page = 1;
					this.navIndex = 7;
					this.getList();
				})
			},
			sureRelease(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let obj = {};
				obj.id = id;
				this.$u.api.shopEvaluationOrderUserConfirmRelease(obj).then(res=>{
          //推送消息
          this.$u.api.shopEvaluationOrderDetails({
            id: id
          }).then(res => {
            let objsend = {};
            let user = uni.getStorageSync("rmUser");
            objsend.user_id = res.data.details.business_id;
            objsend.title = "发布消息";
            objsend.content = '请确认查收-' + res.data.details.ShopEvaluation.title + '-' + user.username +
                '用户稿件已发布，请及时查收。不要让用户久等哦～';;
            objsend.payload = `/pages/pagethree/pages/myCreation/myCreation?form=shop&type=0`;
            app.$vm.sendPushMes(objsend);
          });
					this.$refs.uToast.show({
						title:"已确认发布",
						type:"success",
						duration:2000
					})
					this.page = 1;
					this.navIndex = 6;
					this.getList();
				})
			},
			surePass(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let type = e.target.dataset.type || e.currentTarget.dataset.type;
				let obj = {};
				obj.id = id;
				if(type=="refuse"){
					obj.is_confirm = 2;
				}else if(type=="pass"){
					obj.is_confirm = 1;
				}
				this.$u.api.shopEvaluationOrderShopConfirmShare(obj).then(res=>{
					if(type=="refuse"){
            //推送消息
            this.$u.api.shopEvaluationOrderDetails({
              id: id
            }).then(res => {
              let objsend = {};
              let user = uni.getStorageSync("rmUser");
              objsend.user_id = res.data.details.user_id;
              objsend.title = "驳回消息";
              objsend.content = '请修改稿件后再次提交-' + res.data.details.ShopEvaluation.title +
                  '稿件被驳回，请查看活动详情72小时内补充后再次提交，超时订单将扣除冻结款项支付给商家自动完结，请及时交稿。';
              objsend.payload =
                  `/pages/pagethree/pages/myCreation/myCreation?form=user&type=0`;
              app.$vm.sendPushMes(objsend);
            });
						this.$refs.uToast.show({
							title:"已驳回稿件",
							type:"success",
							duration:2000
						})
						this.page = 1;
						this.navIndex = 5;
						this.getList();
					}else if(type=="pass"){
            //推送消息
            this.$u.api.shopEvaluationOrderDetails({
              id: id
            }).then(res => {
              let objsend = {};
              let user = uni.getStorageSync("rmUser");
              objsend.user_id = res.data.details.user_id;
              objsend.title = "提醒消息";
              objsend.content = '请及时发布作品-' + res.data.details.ShopEvaluation.title +
                  '稿件审核已通过，请及时发布第三方平台后点击（我已发布）';
              objsend.payload =
                  `/pages/pagethree/pages/myCreation/myCreation?form=user&type=0`;
              app.$vm.sendPushMes(objsend);
            });
            this.$refs.uToast.show({
							title:"已确认稿件",
							type:"success",
							duration:2000
						})
						this.page = 1;
						this.navIndex = 6;
						this.getList();
					}
					
				})
			},
			checkMsg(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let type = e.target.dataset.type || e.currentTarget.dataset.type;
				if (type) {
					uni.navigateTo({
						url: "/pages/pagetwo/pages/FindDetail/FindDetail?id=" + id
					})
				} else {
					uni.navigateTo({
						url: "/pages/pagefive/pages/VideoDetail/VideoDetail?id=" + id
					})
				}
			},
			toRelease(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let ids = e.target.dataset.ids || e.currentTarget.dataset.ids;
				if(ids){
					uni.navigateTo({
						url:"/pages/pagefour/pages/Release/Release?id="+ids+"&orderid="+id
					})
				}else{
					uni.navigateTo({
						url:"/pages/pagefour/pages/Release/Release?orderid="+id
					})
				}
			},
			// sureToStore(e){
			// 	let id = e.target.dataset.id || e.currentTarget.dataset.id;
			// 	let obj = {};
			// 	obj.id = id;
			// 	this.$u.api.shopEvaluationOrderUserConfirmBePresent(obj).then(res=>{
			// 		this.$refs.uToast.show({
			// 			title:"已确认到店",
			// 			type:"success",
			// 			duration:2000
			// 		})
			// 		this.page = 1;
			// 		this.navIndex = 5;
			// 		this.getList();
			// 	})
			// },
			sureToStore(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let obj = {};
				obj.id = id;
				this.nowOrderId = id;
				this.sureToStoreFlag = true;
			},
			sureToStoreFun(){
				let obj = {};
				obj.id = this.nowOrderId;
				this.sureToStoreFlag = false;
				uni.chooseImage({
					count:1,
					sourceType:["camera"],
					sizeType:["compressed"],
					success:result=>{
						uni.showLoading({
							title:"上传中..."
						})
						app.$vm.updataAvator(result.tempFilePaths[0]).then(res=>{
							console.log(res)
							obj.arrival_image = res;
							this.$u.api.shopEvaluationOrderUserConfirmBePresent(obj).then(res=>{
								uni.hideLoading()
                //推送消息
                this.$u.api.shopEvaluationOrderDetails({
                  id: this.nowOrderId
                }).then(res => {
                  let objsend = {};
                  let user = uni.getStorageSync("rmUser");
                  objsend.user_id = res.data.details.business_id;
                  objsend.title = "确认消息";
                  objsend.content = '用户' + user.username +
                      '已到店,请确认用户已保存活动要求中所需的图片/视频素材！';
                  objsend.payload =
                      `/pages/pagethree/pages/myCreation/myCreation?form=shop&type=0`;
                  app.$vm.sendPushMes(objsend);
                });
								this.$refs.uToast.show({
									title:"已确认到店",
									type:"success",
									duration:2000
								})
								this.page = 1;
								this.navIndex = 5;
								this.getList();
							})
						});
					},
					fail:err=>{
						if(err.errMsg!='chooseImage:fail cancel'){
							app.$vm.checkAuth("scope.camera").then(resultConfirm=>{
								if(resultConfirm){
									uni.showModal({
										title:"系统繁忙，请稍后再试"
									})
								}else{
									uni.showModal({
										title:"请检查摄像头和相册权限后重试"
									})
								}
							})
						}
					}
				})
			},
			selectTime(e){
				console.log(e)
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let pid = e.target.dataset.pid || e.currentTarget.dataset.pid;
				this.orderIds = id;
				this.appointment_time = Math.floor(new Date(e.detail.value).getTime()/1000);
				uni.$on("confirmTime",(shopId)=>{
					console.log(shopId)
					let obj = {};
					obj.id = this.orderIds;
					obj.appointment_time = this.appointment_time;
					obj.shop_id = shopId;
					this.$u.api.shopEvaluationOrderUserConfirmAppointmentTime(obj).then(res=>{
						this.$refs.uToast.show({
							title:"已预约到店时间",
							type:"success",
							duration:2000
						})
						this.page = 1;
						this.navIndex = 3;
						this.getList();
						uni.$off("confirmTime");
					})
          //推送消息
          this.$u.api.shopEvaluationOrderDetails({
            id: id
          }).then(res => {
            console.log(res)
            let objsend = {};
            let user = uni.getStorageSync("rmUser");
            objsend.user_id = res.data.details.business_id;
            objsend.title = "确认消息";
            objsend.content = '请确认用户预约信息' + user.username + '用户已预约，请及时确认';
            objsend.payload = `/pages/pagethree/pages/myCreation/myCreation?form=shop&type=0`;
            app.$vm.sendPushMes(objsend);
          });
				})
				uni.navigateTo({
					url:"/pages/pageone/pages/choiceStore/choiceStore?userid="+pid
				})
			},
			sureOrder(e){
				let id = e.target.dataset.id || e.currentTarget.dataset.id;
				let money = e.target.dataset.money || e.currentTarget.dataset.money;
				let arr = [];
				// #ifdef MP-WEIXIN
				arr = ["微信支付","余额支付"];
				// #endif
				// #ifdef APP
				arr = ["支付宝支付","微信支付","余额支付"];
				// #endif
				uni.showActionSheet({
					itemList:arr,
					success:res=>{
						let obj = {};
						obj.id = id;
						// #ifdef MP-WEIXIN
						if(res.tapIndex==0){
							obj.pay_type = 10;
							this.sureOrderData = obj;
							this.sureOrderFun();
						}else if(res.tapIndex==1){
							obj.pay_type = 40;
							this.status = "qr";
							this.sureOrderData = obj;
							this.$refs.numberPad.open("需支付"+money+"元");
						}
						// #endif
						// #ifdef APP
						if(res.tapIndex==0){
							obj.pay_type = 30;
							this.sureOrderData = obj;
							this.sureOrderFun();
						}else if(res.tapIndex==1){
							obj.pay_type = 20;
							this.sureOrderData = obj;
							this.sureOrderFun();
						}else if(res.tapIndex==2){
							obj.pay_type = 40;
							this.status = "qr";
							this.sureOrderData = obj;
							this.$refs.numberPad.open("需支付"+money+"元");
						}
						// #endif
					}
				})
			},
			sureOrderFun(){
				this.$u.api.shopEvaluationOrderConfirm(this.sureOrderData).then(res=>{
					if(this.sureOrderData.pay_type==10||this.sureOrderData.pay_type==20){
						wxPayment(JSON.parse(res.data.data.sign)).then(rep=>{
							this.$refs.uToast.show({
								title:"支付成功",
								type:"success",
								duration:2000
							})
							this.page = 1;
							this.navIndex = 3;
							this.getList();
						});
					}else if(this.sureOrderData.pay_type==30){
						zfbPayment(res.data.data).then(rep => {
							this.$refs.uToast.show({
								title:"支付成功",
								type:"success",
								duration:1000
							})
							this.page = 1;
							this.navIndex = 3;
							this.getList();
						})
					}else if(this.sureOrderData.pay_type==40){
						this.$refs.uToast.show({
							title:"支付成功",
							type:"success",
							duration:2000
						})
						this.page = 1;
						this.navIndex = 3;
						this.getList();
					}
				})
        //推送消息
        this.$u.api.shopEvaluationOrderDetails({
          id: this.sureOrderData.id
        }).then(res => {
          let objsend = {};
          objsend.user_id = res.data.details.user_id;
          objsend.title = "确认消息";
          objsend.content = '请登记预约信息-商户已确认并支付稿费到平台，请及时与商户沟通并预约门店和日期';
          objsend.payload = `/pages/pagethree/pages/myCreation/myCreation?form=user&type=0`;
          app.$vm.sendPushMes(objsend);
        });
			},
			getImage(url){
				if(url&&(url.indexOf("http://")!=-1||url.indexOf("https://")!=-1)){
					return url;
				}else{
					return app.$vm.globalData.imgBaseUrl + url;
				}
			},
			getList(){
				let obj = {};
				obj.page = this.page;
				obj.data = {};
				if(this.navIndex==2){
					obj.data.type = '0';
				}else if(this.navIndex==3){
					obj.data.type = '1,2';
				}else if(this.navIndex==4){
					obj.data.type = '3';
				}else if(this.navIndex==5){
					obj.data.type = '4,5';
				}else if(this.navIndex==6){
					obj.data.type = '6,7';
				}else if(this.navIndex==7){
					obj.data.type = '8';
				}
				if(this.form=='shop'){
					obj.data.is_business = 1;
				}else{
					obj.data.is_business = 2;
				}
				this.$u.api.shopEvaluationOrderList(obj).then(res=>{
					console.log(res)
					if(this.page == 1){
						this.list = res.data.list.data.map(cur=>{
							if(cur.ShareImage.length>0){
								if (app.$vm.isImage(cur.ShareImage[0].image_url)) {
									cur.imgType = true;
								} else {
									cur.imgType = false;
								}
							}else{
								cur.imgType = true;
							}
							return cur;
						});
					}else{
						this.list = this.list.concat(res.data.list.data.map(cur=>{
							if(cur.ShareImage.length>0){
								if (app.$vm.isImage(cur.ShareImage[0].image_url)) {
									cur.imgType = true;
								} else {
									cur.imgType = false;
								}
							}else{
								cur.imgType = true;
							}
							return cur;
						}));
					}
					if(this.page<res.data.list.last_page){
						this.moreFlag = true;
					}else{
						this.moreFlag = false;
					}
				})
			},
			selectNav(e){
				let index = e.target.dataset.index || e.currentTarget.dataset.index;
				this.navIndex = index;
				this.page = 1;
				this.getList();
			}
		}
	}
</script>

<style scoped>
	// ````````````````````````````````````````````````
	.toastMark{
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 99998;
		background: rgba(0,0,0,.2);
	}
	.toastWrap{
		width: 540upx;
		padding-top: 56upx;
		border-radius: 12upx;
		background: white;
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%,-50%);
		z-index: 99999;
	}
	.toastWrapTit{
		font-size: 32upx;
		font-weight: bold;
		color: #000000;
		margin-bottom: 32upx;
		width: 100%;
		box-sizing: border-box;
		padding: 0 60upx;
	}
	.toastWrapTit>text{
		font-size: 32upx;
		font-weight: bold;
		color: #FF5555;
	}
	.toastWrapCon{
		font-size: 28upx;
		line-height: 36upx;
		color: #878787;
		width: 100%;
		box-sizing: border-box;
		padding: 0 60upx;
	}
	.toastBtn{
		display: flex;
		margin-top: 40upx;
		border-top: 2upx solid #DDDDDD;
		align-items: center;
	}
	.later{
		width: 50%;
		height: 98upx;
		line-height: 98upx;
		text-align: center;
		border-right: 2upx solid #DDDDDD;
		font-size: 36upx;
		color: #000000;
	}
	.onSure{
		width: 50%;
		height: 98upx;
		line-height: 98upx;
		text-align: center;
		font-size: 36upx;
		color: #108DE9;
	}
	// `````````````````````````````````````````````````
	
	
	::-webkit-scrollbar {
	  display: none;
	  width: 0 !important;
	  height: 0 !important;
	  -webkit-appearance: none;
	  background: transparent;
	}
	.conWrap{
		width: 100%;
		box-sizing: border-box;
		padding: 160upx 24upx 30upx;
	}
	.conItem{
		width: 100%;
		padding: 24upx 24upx 0;
		box-sizing: border-box;
		background: white;
		border-radius: 8upx;
		margin-bottom: 20upx;
	}
	.conItem:last-child{
		margin-bottom: 0;
	}
	.conItemHead{
		display: flex;
		width: 100%;
		align-items: center;
		justify-content: space-between;
	}
	.conItemHeadL{
		display: flex;
		align-items: center;
	}
	.conItemHeadLL{
		width: 24upx;
		height: 24upx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 8upx;
		background: #2EC1F7;
		border-radius: 50%;
	}
	.conItemHeadLL>image{
		width: 16upx;
		height: 16upx;
	}
	.conItemHeadLR{
		font-size: 20upx;
		line-height: 24upx;
		color: #333333;
	}
	.conItemHeadLR>text{
		font-size: 20upx;
		line-height: 24upx;
		color: #FFAC40;
	}
	.conItemHeadR{
		font-size: 20upx;
		line-height: 24upx;
		color: #FF5555;
	}
	.conItemC{
		margin-top: 24upx;
		width: 100%;
		display: flex;
		align-items: center;
	}
	.conItemC>image{
		width: 96upx;
		height: 96upx;
		margin-right: 20upx;
	}
	.conItemCR{
		width: calc(100% - 116upx);
		height: 96upx;
		display: flex;
		flex-direction: column;
		justify-content: center;
	}
	.conItemCRT{
		width: 100%;
		height: 24upx;
		display: flex;
		align-items: center;
	}
	.conItemCRTL{
		width: 48upx;
		height: 24upx;
		margin-right: 8upx;
		border-radius: 4upx;
		background: #260A20;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.conItemCRTL>image{
		width: 24upx;
		height: 24upx;
	}
	.conItemCRTR{
		width: calc(100% - 56upx);
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		line-height: 24upx;
		font-size: 20upx;
		color: #333333;
	}
	.conItemCRC{
		margin: 16upx 0;
		width: 100%;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		font-size: 20upx;
		line-height: 20upx;
		color: #999999;
	}
	.conItemCRC>text{
		font-size: 20upx;
		line-height: 20upx;
		color: #FFAC3F;
	}
	.conItemCRB{
		width: 100%;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		font-size: 20upx;
		line-height: 20upx;
		color: #999999;
	}
	.conItemBWrap{
		display: flex;
		padding: 16upx 0;
		justify-content: space-between;
		border-top: 2upx solid #F5F5F5;
		margin-top: 16upx;
		align-items: center;
	}
	.conItemB{
		display: flex;
		/* padding: 16upx 0; */
		justify-content: flex-end;
		/* border-top: 2upx solid #F5F5F5; */
		/* margin-top: 16upx; */
	}
	.conItemB view{
		/* width: 104upx; */
		height: 52upx;
		text-align: center;
		line-height: 52upx;
		border-radius: 28upx;
		font-size: 20upx;
		color: white;
		padding: 0 16upx;
	}
	.replyApply{
		background: #FFAC3F;
		
	}
	
	
	.navWrap{
		width: 100%;
		height: 56upx;
		box-sizing: border-box;
		/* display: flex; */
		/* align-items: center; */
		/* justify-content: space-between; */
		padding: 0 50upx;
		/* margin: 0 auto; */
		background-color: white;
		
	}
	.navWrap>view{
		white-space: nowrap;
		overflow: auto;
	}
	.navItem{
		font-size: 24upx;
		line-height: 24upx;
		height: 56upx;
		position: relative;
		box-sizing: border-box;
		padding-top: 20upx;
		color: #333333;
		display: inline-block;
		margin-right: 30upx;
	}
	.navItem.active{
		font-weight: bold;
	}
	.navItem.active::after{
		content: "";
		width: 100%;
		height: 4upx;
		position: absolute;
		left: 0;
		bottom: 0;
		background: linear-gradient(90deg, #FFAC3F 0%, #FF801D 100%);
	}
	
	
	.searchWrap{
		width: 100%;
		height: 88upx;
		box-sizing: border-box;
		padding: 0 24upx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: white;
	}
	.searchL{
		width: calc(100% - 100upx);
		display: flex;
		height: 60upx;
		box-sizing: border-box;
		border-radius: 30upx;
		background: #F5F5F5;
		padding: 0 32upx;
		align-items: center;
	}
	.searchL>image{
		width: 32upx;
		height: 32upx;
		margin-right: 10upx;
	}
	.searchL>input{
		width: calc(100% - 42upx);
		height: 60upx;
		font-size: 24upx;
	}
	.searchR{
		font-size: 28upx;
		color: #333333;
		line-height: 60upx;
	}
</style>
